package cn.tx.order.feign.sentinel;


import cn.tx.pojo.domain.Order;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class OrderBlockHandler {
    // 参数必须加上BlockException 不然报错
    public static Order getByIdBlockHandler(@PathVariable("id") Long id, BlockException e) {
        e.printStackTrace();
        return new Order(-1L,"限流","---限流限流---","---限流限流---","---限流限流---");
    }

    // 参数必须加上BlockException 不然报错
    public static List<Order> getListOrderBlockHandler(@RequestParam Map<String, Object> params, BlockException e) {
        e.printStackTrace();
        List<Order> orderList = new ArrayList<>();
        Order order = new Order(-1L, "限流", "---限流限流---", "---限流限流---", "---限流限流---");
        orderList.add(order);
        return orderList;
    }
}
